package com.naxian.service.Impl;

import com.naxian.mapper.MycollectionMapper;
import com.naxian.pojo.Mycollection;

import com.naxian.pojo.MycollectionExample;
import com.naxian.service.mycollection.MycollectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MycollectionServiceImpl implements MycollectionService {
@Autowired
private MycollectionMapper mycollectionMapper;
    @Override
    public boolean insert(Mycollection mycollection) {

        int row= mycollectionMapper.insert(mycollection);
        return row>0;

    }

    @Override
    public Mycollection getByRecId(Integer recId) {
        MycollectionExample mycollectionExample = new MycollectionExample();
        MycollectionExample.Criteria criteria = mycollectionExample.createCriteria();
        criteria.andRecIdEqualTo(recId);
        criteria.andMycollectionStatusEqualTo(1);
        List<Mycollection> mycollectionList = mycollectionMapper.selectByExample(mycollectionExample);
        if(mycollectionList.size()>0) {
            System.out.println("根据职位id查询收藏对象成功");
            Mycollection mycollection = mycollectionList.get(0);
            return mycollection;
        }
        return null;
    }

    @Override
    public boolean update(Mycollection mycollection) {
        int row = mycollectionMapper.updateByPrimaryKey(mycollection);
        return row>0;
    }


}
